﻿namespace MonetDbDataProvider.Mapi
{
    using System.Security.Authentication;

    public static class ExceptionGenerator
    {
        public static void Generate(string monetDbExceptionMessage)
        {
            var exceptionParts = monetDbExceptionMessage.Split(':');

            if (exceptionParts.Length == 0)
                throw new MonetDbException(monetDbExceptionMessage);

            switch (exceptionParts[0])
            {
                case "InvalidCredentialsException":
                    throw new AuthenticationException("Invalid username or password.");
                default:
                    throw new MonetDbException(monetDbExceptionMessage);
            }
        }
    }
}
